package com.young.bs.recruit.web;

import com.young.bs.recruit.model.Job;
import com.young.common.util.Result;
import com.young.interfaces.log.annotation.Log;
import com.young.ums.model.User;
import com.young.ums.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * xxx
 *
 * @author 11
 * @date 2019/5/4
 */
@Controller
public class RegisterController {

    @Resource(name = "userService")
    IUserService userService;

    @Log("查询职位信息列表")
    @RequestMapping(value = "/register", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object register(User obj, HttpServletRequest request) {
        User c = new User();
        c.setAccount(obj.getAccount());

        if (userService.count(c) > 0) {
            return Result.buildFail("账号已被注册");
        }
        obj.setState(1);
        obj.setCompanyId("ROOT");
        userService.insertUserAndSetRole(obj, new String[]{"58067ed97b054f55b255ac6db67ce6fa"});
        return new Result();
    }
}
